package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingPlanDto;
import com.zzyl.service.NursingPlanService;
import com.zzyl.vo.NursingPlanVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/nursing")
@Api(tags = "护理计划")
public class NursingPlanController extends BaseController{
    @Autowired
    private NursingPlanService nursingPlanService;

    @GetMapping("/plan")
    public ResponseResult getListAll() {
        return success(nursingPlanService.getListAll());
    }

    @PostMapping("/plan")
    public ResponseResult insert(@RequestBody NursingPlanDto nursingPlanDto) {
        nursingPlanService.insert(nursingPlanDto);
        return success();
    }

    @GetMapping("/plan/search")
    public ResponseResult<PageResponse<NursingPlanVo>> getListByPage(String name,Integer pageNum,Integer pageSize,Integer status ){
        return success(nursingPlanService.getListByPage(name, pageNum, pageSize, status));
    }

    @GetMapping("/plan/{id}")
    public ResponseResult<NursingPlanVo> getById(@PathVariable Integer id) {
        NursingPlanVo nursingPlanVo = nursingPlanService.getById(id);
        System.out.println(nursingPlanVo);
        return success(nursingPlanVo);
    }

    @PutMapping("/plan/{id}")
    public ResponseResult update(@RequestBody NursingPlanDto nursingPlanDto) {
        nursingPlanService.update(nursingPlanDto);
        return success();
    }

    @DeleteMapping("/plan/{id}")
    public ResponseResult delete(@PathVariable Integer id) {
        nursingPlanService.delete(id);
        return success();
    }

    @PutMapping("/{id}/status/{status}")
    public ResponseResult updateStatus(@PathVariable Integer id, @PathVariable Integer status){
        nursingPlanService.updateStatus(id,status);
        return success();
    }
}
